fix: type Core messenger as AsyncMessenger without provider casts - #138
Closed
ulissesferreira wants to merge 2 commits into
Closed
fix: type Core messenger as AsyncMessenger without provider casts#138ulissesferreira wants to merge 2 commits into
ulissesferreira wants to merge 2 commits into
Conversation
Snap getMessenger returns AsyncMessenger, but SnapExecutionContext typed coreMessenger as the sync Messenger constraint and cast into namespace-bound provider messengers. Introduce MessengerCaller so providers accept a Snap Core endowment (own namespace + action superset) safely, and type tron CoreMessenger as the async runtime value. Co-authored-by: Ulisses Ferreira <ulisses.ferreira@consensys.net>
Co-authored-by: Ulisses Ferreira <ulisses.ferreira@consensys.net>
Contributor
Author
|
Superseded by #139 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Explanation
On main, Core messenger plumbing from #95 has two related type problems that should land before Release/7.0.0 (#137):
CoreMessengervs runtime type mismatch —getMessenger()returnsAsyncMessenger<...>, butSnapExecutionContext.coreMessengerwas typed as the syncMessengerconstraint (TS2740).coreMessenger as AssetsProviderMessenger/as RemoteFeatureFlagsProviderMessengerwere required because provider messenger types were namespace-boundAsyncMessengers ('AssetsProvider'/'RemoteFeatureFlagsProvider'). A Snap Core endowment uses the Snap namespace and often exposes an action superset, so those types are not assignable (especially forRemoteFeatureFlagController:getState).Fix
MessengerCaller/CanCallin@metamask/snap-networks-utils(distributes per-action call overloads over an action union).AssetsProviderMessengerandRemoteFeatureFlagsProviderMessengerasMessengerCallers.CoreMessengerConstraintforgetMessenger, typeCoreMessengerasAsyncMessenger<...>, and remove the casts.This unblocks Solana Core plumbing (#122) from copying the same cast pattern.
References
Checklist